/*
 * Copyright 2011-2025 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0.
 * See `LICENSE` in the project root for license information.
 */

package me.ijleex.platform.framework.minio;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import me.ijleex.platform.framework.minio.util.MinioUtils;

/**
 * MinIO配置.
 *
 * @author liym
 * @since 2024-12-31 23:57 新建
 */
@EnableConfigurationProperties(MinioProperties.class)
@Configuration
public class MinioAutoConfiguration implements InitializingBean {

    private final String endpoint;
    private final String accessKey;
    private final String secretKey;

    public MinioAutoConfiguration(MinioProperties minioProperties) {
        this.endpoint = minioProperties.getEndpoint();
        this.accessKey = minioProperties.getAccessKey();
        this.secretKey = minioProperties.getSecretKey();
    }

    @Override
    public void afterPropertiesSet() {
        MinioUtils.setupClient(this.endpoint, this.accessKey, this.secretKey);
    }

}
